<script src="<?php print $url?>js/data-table.jquery.js"></script>
<script>
  $(function () {
    $('.data-tbl-boxy').dataTable({
        "sPaginationType": "full_numbers",
        "iDisplayLength": 10,
        "oLanguage": {
            "sLengthMenu": "<span class='lenghtMenu'> _MENU_</span><span class='lengthLabel'>Entries per page:</span>",
        },
        "aaSorting": [[1, 'desc']],
        "sDom": '<"tbl-searchbox clearfix"fl<"clear">>,<"table_content"t>,<"widget-bottom"p<"clear">>'

    });
    $('.data-tbl-boxy2').dataTable({
        "sPaginationType": "full_numbers",
        "iDisplayLength": 100,
        "oLanguage": {
            "sLengthMenu": "<span class='lenghtMenu'> _MENU_</span><span class='lengthLabel'>Entries per page:</span>",
        },
        "aaSorting": [[1, 'asc']],
        "sDom": '<"tbl-searchbox clearfix"fl<"clear">>,<"table_content"t>,<"widget-bottom"p<"clear">>'

    });
  });
</script>
<div id="main-content">
  <div class="container-fluid">
    <div class="row-fluid">
      <div class="span6">
        <div class="widget-block">
          <div class="widget-head">
            <h5><?php print $inventory[0]->inventory?></h5>
          </div>
          <div class="widget-content">
            <div class="widget-box">
              <div class="well white-box">
								<h3>Picture</h3>
								<p>
                  <?php
                  if($inventory[0]->picture){
                    print "<img src='".base_url()."/files/mrp/inventory/270/".$inventory[0]->picture."' width='200' />";
                  }
                  else{
                    print "<img src='".base_url()."/files/no-pic.png' width='200' />";
                  }
                  ?>
								</p>
                <h3>SN </h3>
								<p>
									<?php print $this->form_eksternal->form_dropdown("sn", $mrp_inventory, array($inventory[0]->id_mrp_inventory_department), "id='sn'")?>
                  <br />
                  <a class="btn" href="<?php print site_url("mrp/asset/schedule/".$inventory[0]->id_mrp_inventory_department)?>">Schedule</a>
                  <a class="btn" href="<?php print site_url("mrp/asset/add-inventory-department/{$inventory[0]->id_hrm_department}/".$inventory[0]->id_mrp_inventory_department)?>">Edit</a>
								</p>
								<h3>Brand</h3>
								<p>
									<?php print $inventory[0]->brand?>
								</p>
								<h3>Date</h3>
								<p>
									<?php print $inventory[0]->tanggal?>
								</p>
								<h3>Guatrantee</h3>
								<p>
									<?php print $inventory[0]->guarantee?>
								</p>
								<h3>Expired</h3>
								<p>
									<?php print $inventory[0]->expired?>
								</p>
								<h3>Penanggungjawab Inventory</h3>
								<p>
									<?php print $inventory[0]->pi?>
								</p>
								<h3>Last PIC</h3>
								<p>
									<?php print $inventory[0]->pic?>
								</p>
								<h3>Note</h3>
								<p>
									<?php print nl2br($inventory[0]->note)?>
								</p>
							</div>
            </div>
          </div>
        </div>
      </div>
      <div class="span6">
        <div class="widget-block">
          <div class="widget-head">
            <h5>History</h5>
            <div class="widget-control pull-right">
              <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="<?php print   site_url("mrp/asset/add-history-inventory/".$inventory[0]->id_mrp_inventory_department) ?>"><i class="icon-plus"></i> Add History</a></li>
              </ul>
            </div>
          </div>
          <div class="widget-content">
            <div class="widget-box">
              <table class="data-tbl-boxy table">
                <thead>
                  <tr>
                    <th>Title</th>
                    <th>Date</th>
                    <th>Option</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td>Pengadaan Barang</td>
                    <td><?php print $inventory[0]->tanggal?></td>
                    <td></td>
                  </tr>
                  <?php
                  if(is_array($history)){
                    foreach ($history as $key => $value) {
                      print "
                  <tr>
                    <td>
                      <ul>
                        <li>Title: <a class='btn-modal' data-toggle='modal' href='#myModal{$value->id_mrp_history_inventory}'>{$value->title}</a></li>
                        <li class='post-by'><i class='icon-small-black user_sc'></i> PIC: {$value->pic}</li>
                      </ul>
                      <div class='modal hide fade' id='myModal{$value->id_mrp_history_inventory}'>
                        <div class='modal-header'>
                          <button type='button' class='close' data-dismiss='modal'>×</button>
                          <h3>{$value->title}</h3>
                        </div>
                        <div class='modal-body'>
                          <p>
                            ".  nl2br($value->note)."
                          </p>
                        </div>
                        <div class='modal-footer'>
                          <a href='#' class='btn' data-dismiss='modal'>Close</a>
                        </div>
                      </div>
                    </td>
                    <td>
                      <a class='btn-modal' data-toggle='modal' href='#myTanggal{$value->id_mrp_history_inventory}'>{$value->tanggal}</a>
                      <div class='modal hide fade' id='myTanggal{$value->id_mrp_history_inventory}'>
                        <div class='modal-header'>
                          <button type='button' class='close' data-dismiss='modal'>×</button>
                          <h3>{$value->title}</h3>
                        </div>
                        <div class='modal-body'>
                          <p>
                            <ul>
                              <li>Start: {$value->tanggal} {$value->timein}</li>
                              <li>Finish: {$value->finish} {$value->timeout}</li>
                            </ul>
                          </p>
                        </div>
                        <div class='modal-footer'>
                          <a href='#' class='btn' data-dismiss='modal'>Close</a>
                        </div>
                      </div>
                    </td>
                    <td>
                      <div class='btn-group pull-right'>
                        <button data-toggle='dropdown' class='btn dropdown-toggle'><i class='icon-cog'></i><span class='caret'></span></button>
                        <ul class='dropdown-menu'>
                          <li><a href='".site_url("mrp/asset/add-history-inventory/".$inventory[0]->id_mrp_inventory_department."/".$value->id_mrp_history_inventory)."'><i class='icon-edit'></i> Edit</a></li>
                          <li><a href='#'><i class='icon-minus-sign'></i> Delete</a></li>
                        </ul>
                      </div>
                    </td>
                  </tr>";
                    }
                  }
                  ?>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="row-fluid">
      <div class="span6">
        <div class="widget-block">
          <div class="widget-head">
            <h5>Penyusutan</h5>
            <div class="widget-control pull-right">
              <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="<?php print   site_url("mrp/asset/add-history-penyusutan/".$inventory[0]->id_mrp_inventory_department) ?>"><i class="icon-plus"></i> Add Penyusutan</a></li>
              </ul>
            </div>
          </div>
          <div class="widget-content">
            <div class="widget-box">
              <table class="data-tbl-boxy2 table">
                <thead>
                  <tr>
                    <th>Title</th>
                    <th>Date</th>
                    <th>Nilai</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  if(is_array($penyusutan)){
                    foreach ($penyusutan as $key => $value) {
                      print "
                  <tr>
                    <td>
                      <a class='btn-modal' data-toggle='modal' href='#myModal{$value->id_mrp_history_inventory}'>{$value->title}</a>
                      <div class='modal hide fade' id='myModal{$value->id_mrp_history_inventory}'>
                        <div class='modal-header'>
                          <button type='button' class='close' data-dismiss='modal'>×</button>
                          <h3>{$value->title}</h3>
                        </div>
                        <div class='modal-body'>
                          <p>
                            ".  nl2br($value->note)."
                          </p>
                        </div>
                        <div class='modal-footer'>
                          <a href='#' class='btn' data-dismiss='modal'>Close</a>
                        </div>
                      </div>
                    </td>
                    <td>
                      {$value->tanggal}
                    </td>
                    <td>
                      <div class='pull-right'>
                        ".  number_format($value->nilai, 0, ",", ".")."
                      </div>
                    </td>
                  </tr>";
                      $jumlah += $value->nilai;
                    }
                  }
                  ?>
                  <tr>
                    <td><b>Nilai Akhir</b></td>
                    <td><span style="display: none">9999-99-99</span></td>
                    <td>
                      <div class='pull-right'><b><?php print number_format($jumlah, 0, ",", ".")?></b></div>
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
  $(document).ready( function () {
    
    $("#sn").change(function(){
      window.location = "<?php print site_url("mrp/asset/history-inventory/{$inventory[0]->id_hrm_department}/".$inventory[0]->id_mrp_inventory)?>/"+$("#sn").val();
    });
  });
</script>